//
//  UILable+Extension.swift
//  sinaWeiBo
//
//  Created by smartlei on 15/10/15.
//  Copyright © 2015年 smartlei. All rights reserved.
//

import UIKit

//MARK - UILabel的便利构造函数
extension UILabel {
    
    //便利构造函数
    convenience init(labText: String,labTextColor: UIColor = UIColor.darkGrayColor()  ,fontSize: CGFloat = 15,textInset: CGFloat = 0) {
        
        //创建Label
        self.init()
        //1 设置文字
        text = labText
        //2 设置字号
        font = UIFont.systemFontOfSize(fontSize)
        //3 设置字体颜色:深灰
        textColor = labTextColor
        //4 设置多行
        numberOfLines = 0
        //5 设置中心对其
        if textInset == 0  {
            textAlignment = NSTextAlignment.Center
        }
        else {
            textAlignment = .Left
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * textInset
            
        }
    }
}
